import {createRouter, createWebHashHistory} from "vue-router"
import layout from "../layout/index.vue"

/**
 * 私有路由
 */
export const privateRoutes = [
    {
        path: "/article",
        component: layout,
        redirect: "/article/ranking",
        name: "articleRanking",
        meta:
            {
                title: "文章",
                //icon: import.meta.env.VITE_APP_BASE_API + "/assets/icon/svg/user.svg"
                icon: "Avatar"
            },
        children: [
            {
                path: "/article/ranking",
                component: () =>
                    import(
                        /* webpackChunkName: "article-ranking" */ "../views/article-ranking/index.vue"
                        ),
                meta: {
                    title: "文章列表",
                    // icon: import.meta.env.VITE_APP_BASE_API + "/assets/icon/svg/user.svg"
                    icon: "Avatar"
                }
            },
            {
                path: "/article/:id",
                component: () =>
                    import(
                        /* webpackChunkName: "article-ranking" */ "../views/article-detail/index.vue"
                        ),
                meta: {
                    title: "文章详情"
                }
            }
        ]
    },
    {
        path: "/user",
        component: layout,
        redirect: "/user/manage",
        meta: {
            title: "用户",
            //icon: import.meta.env.VITE_APP_BASE_API + "/assets/icon/svg/user-1.svg"
            icon: "Avatar"
        },
        children: [
            {
                path: "/user/manage",
                name: "userManage",
                component: () => import("../views/user-manage/index.vue"),
                meta: {
                    title: "用户管理",
                    //icon: import.meta.env.VITE_APP_BASE_API +  "/assets/icon/svg/user.svg"
                    icon: "Avatar"
                }
            },
            {
                path: "/user/role",
                name: "/userRole",
                component: () => import("../views/role-list/index.vue"),
                meta: {
                    title: "角色列表",
                    //icon: import.meta.env.VITE_APP_BASE_API +  "/assets/icon/svg/user.svg"
                    icon: "Avatar"
                }
            },
            {
                path: "/user/permission",
                name: "userPermission",
                component: () => import("../views/permission-list/index.vue"),
                meta: {
                    title: "权限列表",
                    //icon: import.meta.env.VITE_APP_BASE_API +  "/assets/icon/svg/user.svg"
                    icon: "Avatar"
                }
            },
            {
                path: "/user/info/:id",
                component: () => import("../views/user-info/index.vue"),
                meta: {
                    title: "用户信息",
                }
            },
            {
                path: "/user/import",
                name: "import",
                component: () => import("../views/import/index.vue"),
                meta: {
                    title: "excel导入",
                }
            },
        ]
    },
]

/**
 *公有路由
 */
export const publicRoutes = [
    {
        name: "登录",
        path: "/login",
        component: () => import("../views/login/index.vue")
    },
    {
        path: "/",
        redirect: "/profile",
        component: () => import("../layout/index.vue"),
        children: [
            {
                path: "/profile",
                name: "profile",
                component: () => import("../views/profile/index.vue"),
                meta: {
                    title: "用户信息",
                    //icon: import.meta.env.VITE_APP_BASE_API +  "/assets/icon/svg/user.svg"
                    icon: "Avatar"
                }
            },
            //404
            {
                path: "/404",
                name: "404",
                component: () => import("../views/error-page/404.vue")
            },
            //401
            {
                path: "/401",
                name: "401",
                component: () => import("../views/error-page/401.vue")
            },
        ]
    },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes: [...publicRoutes, ...privateRoutes]
})

export default router